next permutation solution

join shbcf.ru